# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/register.html'
driver.get(url)

# 1.打开register.html
# 2.填写主页面 页面信息
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#password').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#tel').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#email').send_keys('123@qq.com')

# 切换到内嵌的页面，提供iframe元素的id、name、定位的元素
# driver.switch_to.frame('idframe1')
# driver.switch_to.frame('myframe1')
element = driver.find_element(By.CSS_SELECTOR, '[src="registerA.html"]')
driver.switch_to.frame(element)
# 3.填写注册A 页面信息
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telA').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailA').send_keys('123@qq.com')
# 4.填写注册B 页面信息
# 切换回到主页面
driver.switch_to.default_content()
# 切换到B页面
driver.switch_to.frame('myframe2')
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userB').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordB').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telB').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailB').send_keys('123@qq.com')
sleep(3)
driver.quit()